import 'package:flutter/material.dart';
import 'package:flutter_enjoy/pages/Home/Home.dart';
import 'package:flutter_enjoy/pages/Mine/Mine.dart';



class TabsPage extends StatefulWidget {
  const TabsPage({super.key});

  @override
  // ignore: library_private_types_in_public_api
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> {
  int currentIndex = 0;
  List tabList = [
    {
      'label': '首页',
      'icon': 'assets/tabs/home_default.png',
      'activeIcon': 'assets/tabs/home_active.png'
    },
    {
      'label': '我的',
      'icon': 'assets/tabs/my_default.png',
      'activeIcon': 'assets/tabs/my_active.png'
    }
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: IndexedStack(
          index: currentIndex,
          children:  [
            Center(
              child: Home(),
            ),
            Center(
              child: Mine(),
            ),
          ],
        ),
        bottomNavigationBar: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          selectedItemColor: const Color.fromARGB(255, 188, 221, 238),
          unselectedItemColor: Colors.black,
          selectedFontSize: 13,
          unselectedFontSize: 12,
          currentIndex: currentIndex,
          onTap: (int index) {
            setState(() {
              currentIndex = index;
            });
          },
          items: tabList.map<BottomNavigationBarItem>((item) {
            return BottomNavigationBarItem(
              label: item['label'],
              icon: Image.asset(
                item['icon'],
                width: 24,
                height: 24,
              ),
              activeIcon: Image.asset(
                item['activeIcon'],
                width: 24,
                height: 24,
              ),
            );
          }).toList(),
        ));
  }
}
